﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace D20.Entities
{
    /// <summary>
    /// An <see cref="Entity"/>'s identity.
    /// </summary>    
    public class Identity
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Identity"/> class.
        /// </summary>
        public Identity()
            : this(Guid.NewGuid())
        {

        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Identity"/> class.
        /// </summary>
        /// <param name="identifier">The GUID.</param>
        public Identity(Guid identifier)
            : this(identifier.ToString(), identifier)
        {

        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Identity"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="identifier">The GUID.</param>
        public Identity(string name, Guid identifier)
        {
            Name = name;
            Guid = identifier;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Identity"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        public Identity(string name)
            : this(name, Guid.NewGuid())
        {

        }

        /// <summary>
        /// Gets the identity's GUID.
        /// </summary>
        /// <value>The GUID.</value>
        [ReadOnly(true)]
        public Guid Guid { get; private set; }
        /// <summary>
        /// Gets or sets the name .
        /// </summary>
        /// <value>The name.</value>
        public string Name { get; set; }
    }
}
